#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

echo "Running pre-push hook"

# 获取当前分支名称
current_branch=$(git branch --show-current)

echo "Current branch is $current_branch"

# 检查是否是master分支
if [ "$current_branch" = "master" ]; then
    echo "Pre-push hook is running on master branch"
    echo $OSTYPE
    
    dirPath="Unknown OS"
    param="Unknown OS"
    
    if [[ "$OSTYPE" == "darwin"* ]]; then
        echo "Running on Mac"
        dirPath="/Users/edy/Desktop/cheny/code/biye-cicd"
        param="mac:study-notes"
        elif [[ "$OSTYPE" == "msys"* ]] || [[ "$OSTYPE" == "win32" ]]; then
        echo "Running on Windows"
        dirPath="D:/code/cheny/biye-cicd"
        param="window:study-notes"
    else
        echo "Unknown OS"
        exit 1
    fi
    cd $dirPath
    node app.js $param
else
    echo "Not on master branch, skipping pre-push hook"
fi